{extend name="../template/index/base.html"}
{block name="title"}{$artice.title}-{$info['webname']}{/block}
{block name="keywords"}{$info['keyword']}{/block}
{block name="description"}{$info['description']}{/block}
{block name="content"}	
			<div class="layui-col-md8"> 
				<div class="fly-panel detail-box"> 
					<div class="actitle">
						{$artice.title}
					</div> 
					<div class="auinfo"> 
						<li><i class="layui-icon"></i>
						{eq name="$artice.author" value=""}
							{$user.nickname}
						{else/}
							{$artice.author}
						{/eq}
						</li> 
						<li><i class="layui-icon"></i>
						{$artice.time|date='Y-m-d',###}
						</li> 
						<li><i class="layui-icon"></i> <a href="../category/{$artice.cid}">{$cat.name}</a></li> 
					</div> 
					<div class="detail-body photos clb"> 
						{$artice.content|str_replace='../../../',dirname($_SERVER['SCRIPT_NAME']),###}
					</div> 
					<div class="zaninfo"> 
						<p class="zanz"> <a href="javascript:;" onclick="aczan({$artice.id})">赞( <span id="ac{$artice.id}">{$artice.zan}</span> )</a> </p> 
						<p class="zans"> <a href="javascript:;" onclick="good()">赞赏</a> </p> 
					</div> 
				</div> 
				<div class="layui-card"> 
					<div class="layui-card-body nextinfo"> 
						<i class="layui-icon"></i> 
						<a href="../article/{$downartice.id}">{$downartice.title}</a>
						<br /> 
						<i class="layui-icon"></i> 
						<a href="../article/{$upartice.id}">{$upartice.title}</a>
					</div> 
				</div> 
				<div class="fly-panel detail-box" id="flyReply"> 
					<fieldset class="layui-elem-field layui-field-title" style="text-align: center;"> 
						<legend>评论</legend> 
					</fieldset> 
					<ul class="jieda" id="jieda"> 

						{volist name="comment" id="comment"}
						<div class="detail-about detail-about-reply"> 
							<a class="fly-avatar" href="{$comment.url}"> <img src="http://www.gravatar.com/avatar/{$comment.mail|md5}?s=64" alt=" " /> </a> 
							<div class="fly-detail-user"> 
								<a href="{$comment.url}" class="fly-link"><cite>{$comment.name}</cite> </a> 
							</div> 
							<div class="detail-hits"> 
								<span>{$comment.time|date='Y-m-d H:i:s',###}</span> 
							</div> 
						</div> 
						<div class="detail-body jieda-body photos"> 
							<p>{$comment.text}</p> 
						</div> 
						<div class="jieda-reply"> 
							<span type="reply"> 
								<div class="jieda-admin" onclick="atAdd('{$comment.uid}','{$comment.name}')"> 
									<a href="#tjpl" class="hui"> <i class="iconfont icon-svgmoban53"></i> 回复</a>  
								</div> </span>
							</div>  
						{/volist}

								{empty name="comment"}
								<li class="fly-none">消灭零回复</li>
								{/empty}
								<li class="fly-none" id="tjpl"></li> 
							</ul> 
							<div class="layui-form layui-form-pane"> 
								<form> 
								{:token()}
								<input type="hidden" name="id" value="{$artice.id}">
								<input type="hidden" id="com_id" name="com_id">
									<div class="layui-form-item"> 
										<label class="layui-form-label">昵称</label> 
										<div class="layui-input-block"> 
											<input type="text" name="name"  lay-verify="required" placeholder="请输入你的昵称" autocomplete="off" class="layui-input" value="{:cookie('visitorname')}" /> 
										</div> 
									</div> 
									<div class="layui-form-item"> 
										<label class="layui-form-label">网址</label> 
										<div class="layui-input-block"> 
											<input type="text" name="url" lay-verify="url" placeholder="请输入你的网址" autocomplete="off" class="layui-input" value="{:cookie('visitorurl')}" /> 
										</div> 
									</div> 
									<div class="layui-form-item"> 
										<label class="layui-form-label">邮箱</label> 
										<div class="layui-input-block"> 
											<input type="text" name="email" lay-verify="email" placeholder="请输入你的邮箱" autocomplete="off" class="layui-input" value="{:cookie('visitoremail')}" /> 
										</div> 
										<input type="checkbox" name="onemail" title="有人回复时邮件通知我" lay-skin="primary" /> 
									</div> 
									<div class="layui-form-item layui-form-text"> 
										<a name="comment"></a> 
										<div class="layui-input-block"> 
											<textarea id="L_content" name="content" placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 80px;"></textarea> 
										</div> 
									</div> 
									<div class="layui-form-item"> 
										<button class="layui-btn fr" lay-filter="reply" lay-submit="submit" id="sendreply">提交回复</button> 
									</div> 
								</form> 
							</div> 
						</div> 
					</div> 
{/block}
{block name="jssrc"}
<script type="text/javascript">
function atAdd(replyerid,username){
	layui.use(['jquery','form','layedit'],function(){
		var layedit = layui.layedit;
		var form = layui.form; 
		var $ = layui.$;
		var name = username;
		$('#com_id').val(replyerid);
		$('#L_content').val('@'+name+' ,');
		index = layedit.build('L_content', {
			height: 180,
			tool: ['face']
  		}); //渲染编辑器
	});
}
//点赞
function aczan(acid){
	layui.use('jquery',function(){
		var $ = layui.$;
		zan = $('#ac'+acid).html();
		if (checkcookie(acid) == true) {
		$.ajax({
		type:"POST",
		url:"../zan",
		dataType:"json",
		data: {id:acid},
		error: function (XmlHttpRequest, textStatus, errorThrown) {
			if (XmlHttpRequest.responseText != "") {
				layer.closeAll('loading');
				layer.msg('点赞失败，请稍后尝试！');
			}
		},
		success:function(data){
            if (data.result == "1") {
            	layer.closeAll('loading');
            	$('#ac'+acid).html(parseInt(zan)+1);
            	layer.msg('点赞成功');
            }
        }
    });
		}else{
			layer.msg('你已经点过赞了');
		}
	});
}

function checkcookie(gindex){
	var thiscookie = 'acid' + gindex;
	var mapcookie = getCookie(thiscookie)
	if (mapcookie!=null && mapcookie!=""){
		return false;
	}else {
		setCookie('acid'+gindex,'ac'+gindex);
		return true;
	} 
}

function getCookie(c_name){
	 if (document.cookie.length > 0){
		 c_start = document.cookie.indexOf(c_name + "=");
		 if (c_start != -1){
			 c_start = c_start + c_name.length + 1 ;
			 c_end = document.cookie.indexOf(";" , c_start);
			 if (c_end == -1) {
				  c_end = document.cookie.length;
			 }
			 return unescape(document.cookie.substring(c_start , c_end));
		 } 
	 }
	 return "";
 }

function setCookie(name,value) 
{ 
	var Days = 30; 
	var exp = new Date(); 
	exp.setTime(exp.getTime() + Days*24*60*60*3600); 
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
} 

layui.use(['layer', 'form', 'element'], function(){
	var layer = layui.layer
	,form = layui.form;
});
function good(){
	layer.open({
		title:'赞赏',
		type: 1,
  	area: ['300px', '443px'], //宽高
  	content: '<img src="./layui/images/good.png">'
  });
}
layui.use('util', function(){
	var util = layui.util;
	util.fixbar({
		bgcolor:'#333',
		bar1: true
		,click: function(type){
			if(type === 'bar1'){
				layer.msg('分享美好时光')
			}
		}
	});
});
layui.use(['layedit','jquery','form'], function(){
	var layedit = layui.layedit;
	form = layui.form;
	var $ = layui.$;
	var index = layedit.build('L_content', {
		tool: ['face'],
		height: 180
  }); //建立编辑器

$("#sendreply").click(function(){
//同步编辑器内容
layedit.sync(index);
form.on('submit(reply)', function(data){
	$.ajax({
		type:"POST",
		url:'../reply',
		dataType:"json",
		data: data.field,
		beforeSend: function () {
			$("#sendreply").attr({"disabled":"disabled"});
			$("#sendreply").addClass("layui-btn-disabled");
			$("#sendreply").html("正在回复中...");
			layer.load(1);
		},
		error: function (XmlHttpRequest, textStatus, errorThrown) {
			if (XmlHttpRequest.responseText != "") {
				layer.closeAll('loading');
				layer.msg('提交失败，请稍后尝试！');
				$("#sendreply").removeClass("layui-btn-disabled");
				$("#sendreply").removeAttr("disabled");  
				$("#sendreply").html("提交回复");
			}
		},
		success:function(data){
            if (data.result == "1") {
            	layer.msg(data.msg);
            	layer.closeAll('loading');
            	$("#sendreply").removeClass("layui-btn-disabled");
            	$("#sendreply").removeAttr("disabled");  
            	$("#sendreply").html("提交回复");
            	setTimeout(function(){
            		location.reload();
            	},1000);
            }else if(data.result = "2"){
            	layer.closeAll('loading');
            	layer.msg(data.msg);
            	$("#sendreply").removeClass("layui-btn-disabled");
            	$("#sendreply").removeAttr("disabled");  
            	$("#sendreply").html("提交回复");

            }
        }
    });
	return false;
});
});
});
</script>
{/block}